package TestDemo1;

abstract class Fruits {

    abstract void colour();

}
class Red extends Fruits {

    @Override
    public void colour() {
        System.out.println("红 ");
    }

}
class Yellow extends Fruits{

    @Override
    public void colour() {
        System.out.println("黄 ");
    }

}
class Green extends  Fruits{

    @Override
    void colour() {
        System.out.println("绿 ");
    }
}

public class Test {
    public static void draw() {
       // 红 红 绿 红 绿 黄
        Red red=new Red();
        Green green=new Green();
        Yellow yellow=new Yellow();
        Fruits [] fruits={new Red(),new Red(),new Green(),new Red(),new Green(),new Yellow()};
        for (Fruits colouR:fruits) {
           colouR.colour();
        }
    }

    public static void main(String[] args) {
      draw();
    }

}
